package com.gitee.wsl.mathematics.vector.bool.ext

import com.gitee.wsl.mathematics.number.compareTo
import com.gitee.wsl.mathematics.vector.vec2.Vector2
import com.gitee.wsl.mathematics.vector.bool.BooleanVector2

fun <T:Number> lessThan(a: Vector2<T,*>, b: T) = BooleanVector2(a.x < b, a.y < b)
fun <T:Number> lessThan(a: Vector2<T,*>, b: Vector2<T,*>) = BooleanVector2(a.x < b.x, a.y < b.y)
fun <T:Number> lessThanEqual(a: Vector2<T,*>, b: T) = BooleanVector2(a.x <= b, a.y <= b)
fun <T:Number> lessThanEqual(a: Vector2<T,*>, b: Vector2<T,*>) = BooleanVector2(a.x <= b.x, a.y <= b.y)
fun <T:Number> greaterThan(a: Vector2<T,*>, b: T) = BooleanVector2(a.x > b, a.y > b)
fun <T:Number> greaterThan(a: Vector2<T,*>, b: Vector2<T,*>) = BooleanVector2(a.x > b.y, a.y > b.y)
fun <T:Number> greaterThanEqual(a: Vector2<T,*>, b: T) = BooleanVector2(a.x >= b, a.y >= b)
fun <T:Number> greaterThanEqual(a: Vector2<T,*>, b: Vector2<T,*>) = BooleanVector2(a.x >= b.x, a.y >= b.y)
fun <T:Number> equal(a: Vector2<T,*>, b: T) = BooleanVector2(a.x == b, a.y == b)
fun <T:Number> equal(a: Vector2<T,*>, b: Vector2<T,*>) = BooleanVector2(a.x == b.x, a.y == b.y)
fun <T:Number> notEqual(a: Vector2<T,*>, b: T) = BooleanVector2(a.x != b, a.y != b)
fun <T:Number> notEqual(a: Vector2<T,*>, b: Vector2<T,*>) = BooleanVector2(a.x != b.x, a.y != b.y)

infix fun <T:Number> Vector2<T,*>.lt(b: T) = BooleanVector2(x < b, y < b)
infix fun <T:Number> Vector2<T,*>.lt(b: Vector2<T,*>) = BooleanVector2(x < b.x, y < b.y)
infix fun <T:Number> Vector2<T,*>.lte(b: T) = BooleanVector2(x <= b, y <= b)
infix fun <T:Number> Vector2<T,*>.lte(b: Vector2<T,*>) = BooleanVector2(x <= b.x, y <= b.y)
infix fun <T:Number> Vector2<T,*>.gt(b: T) = BooleanVector2(x > b, y > b)
infix fun <T:Number> Vector2<T,*>.gt(b: Vector2<T,*>) = BooleanVector2(x > b.x, y > b.y)
infix fun <T:Number> Vector2<T,*>.gte(b: T) = BooleanVector2(x >= b, y >= b)
infix fun <T:Number> Vector2<T,*>.gte(b: Vector2<T,*>) = BooleanVector2(x >= b.x, y >= b.y)
infix fun <T:Number> Vector2<T,*>.eq(b: T) = BooleanVector2(x == b, y == b)
infix fun <T:Number> Vector2<T,*>.eq(b: Vector2<T,*>) = BooleanVector2(x == b.x, y == b.y)
infix fun <T:Number> Vector2<T,*>.neq(b: T) = BooleanVector2(x != b, y != b)
infix fun <T:Number> Vector2<T,*>.neq(b: Vector2<T,*>) = BooleanVector2(x != b.x, y != b.y)

fun  any(v: BooleanVector2) = v.x || v.y

fun  all(v: BooleanVector2) = v.x && v.y